<template>
  <a-card :bordered="false">
    <div style="display: flex; justify-content: space-between">
      <!-- 操作按钮区域 -->
      <div class="table-operator">
        <!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('订单表')">导出</a-button>
      <a-upload
        name="file"
        :showUploadList="false"
        :multiple="false"
        :headers="tokenHeader"
        :action="importExcelUrl"
        @change="handleImportExcel"
      >
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload> -->
        <a-dropdown v-if="selectedRowKeys.length > 0">
          <a-menu slot="overlay">
            <a-menu-item key="1" @click="batchDel"><a-icon type="delete" />删除</a-menu-item>
          </a-menu>
          <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
        </a-dropdown>
      </div>
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-form-item label="城市服务商" style="margin-right: 10px" v-has="'xhdjBalanceRecharge:select'">
            <serveSelect @selectClick="selectClick" :value="queryParam.agencyCode"></serveSelect>
          </a-form-item>
          <a-form-item label="用户编号" style="margin-right: 10px">
            <a-input placeholder="请输入用户编号" v-model="queryParam.userId" @pressEnter="searchQuery"></a-input>
          </a-form-item>
          <a-form-item label="用户手机号" style="margin-right: 10px">
            <a-input placeholder="请输入用户手机号" v-model="queryParam.phone" @pressEnter="searchQuery"></a-input>
          </a-form-item>
          <a-form-item label="充值订单号" style="margin-right: 10px">
            <a-input placeholder="请输入充值订单号" v-model="queryParam.orderNo" @pressEnter="searchQuery"></a-input>
          </a-form-item>
          <a-form-item label="商户订单号" style="margin-right: 10px">
            <a-input
              placeholder="请输入商户订单号"
              v-model="queryParam.transactionNo"
              @pressEnter="searchQuery"
            ></a-input>
          </a-form-item>
          <a-form-item label="推荐技师手机号" style="margin-right: 10px">
            <a-input placeholder="请输入手机号" v-model="queryParam.referencePhone" @pressEnter="searchQuery"></a-input>
          </a-form-item>
          <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
            <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
            <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
          </span>
        </a-form>
      </div>
    </div>
    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <span style="margin-right: 20px"
          >充值总金额：<span style="font-size: 16px; color: red">{{ parseFloat(totalMoney || 0).toFixed(2) }} </span
          >元</span
        >
        <span style="margin-right: 20px"
          >充值单数：<span style="font-size: 16px; color: red">{{ orderNum || 0 }} </span>单</span
        >
      </div>
    </div>
    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      class="j-table-force-nowrap"
      @change="handleTableChange"
    >
    </a-table>
    <!-- table区域-end -->
    <!-- 表单区域 -->
    <!-- <xhdjOrderInfo-modal ref="modalForm" @ok="modalFormOk"></xhdjOrderInfo-modal> -->
    <!-- <XhdjOrderInfoDialog ref="dialogForm"></XhdjOrderInfoDialog> -->
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
// import XhdjOrderInfoModal from './modules/XhdjOrderInfoModal'
import { getAction, httpAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import serveSelect from '@/components/serveSelect.vue'
// import XhdjOrderInfoDialog from './modules/XhdjOrderInfoDialog.vue'
export default {
  name: 'xhdjBalanceRechargeList',
  mixins: [JeecgListMixin],
  components: {
    serveSelect
  },
  data () {
    return {
      description: '订单表管理页面',
      options: [
        { label: '车费', value: '0' },
        { label: '服务', value: '1' }
      ],
      payTypes: {
        2: '支付宝',
        3: '微信APP',
        4: '微信公众号(备用)',
        5: '微信公众号(备用)',
        6: '微信公众号(备用)',
        7: '微信公众号(忘忧到家)'
      },
      payStatus: {
        0: '待支付',
        1: '已支付',
        2: '已取消'
      },
      orderNum: 0,
      totalMoney: 0,
      // 表头
      columns: [
        {
          title: '用户编码',
          align: 'center',
          dataIndex: 'userId'
        },
        {
          title: '用户昵称',
          align: 'center',
          dataIndex: 'nickName'
        },
        {
          title: '用户手机号',
          align: 'center',
          dataIndex: 'phone'
        },
        {
          title: '推荐人手机号',
          align: 'center',
          dataIndex: 'referencePhone'
        },
        {
          title: '充值订单号',
          align: 'center',
          dataIndex: 'orderNo'
        },
        {
          title: '商户订单号',
          align: 'center',
          dataIndex: 'transactionNo'
        },
        {
          title: '支付方式',
          align: 'center',
          dataIndex: 'payType',
          customRender: (text, record) => {
            return this.payTypes[record.payType]
          }
        },
        {
          title: '实际支付金额',
          align: 'center',
          dataIndex: 'payAmount'
        },
        {
          title: '订单总金额',
          align: 'center',
          dataIndex: 'totalAmount'
        },
        {
          title: '支付状态',
          align: 'center',
          dataIndex: 'payStatus',
          customRender: (text, record) => {
            return this.payStatus[record.payStatus]
          }
        },
        {
          title: '创建日期',
          align: 'center',
          dataIndex: 'createTime'
        }
      ],
      typeW: 2,
      url: {
        list: '/user/xhdjUserBalanceRecord/list',
        listes: '/user/xhdjUserBalanceRecord/statistics'
      }
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  created () {
    this.init()
  },
  methods: {
    // 通过
    handlePass (id) {
      getAction(this.url.passUrl, { id }).then(res => {
        if (res.code == 200) {
          that.$message.success(res.message)
          this.loadData()
        } else {
          that.$message.console.error(res.message)
        }
      })
    },
    init () {
      var params = this.getQueryParams() //查询条件
      httpAction(this.url.listes, params, 'post').then(res => {
        if (res.code === 200) {
          let { orderNum, totalMoney } = res.result
          this.orderNum = orderNum
          this.totalMoney = totalMoney
        }
      })
    },
    selectClick (value) {
      this.queryParam.agencyCode = value
      this.searchQuery()
    },
    handleReject (id) {
      getAction(this.url.reject, { id }).then(res => {
        if (res.code == 200) {
          that.$message.success(res.message)
          this.loadData()
        } else {
          that.$message.console.error(res.message)
        }
      })
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
.ant-row {
  display: flex;
  justify-content: flex-end;
}
.ant-col {
  display: flex;
  justify-content: flex-end;
}
.ant-form {
  display: flex;
}
</style>
